package com.tsingteng.cosfun.ui.message.messagereport;

import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.base.BasePresenterFragment;
import com.tsingteng.cosfun.bean.MessageReportBean;
import com.tsingteng.cosfun.common.Navigate;
import com.tsingteng.cosfun.helper.VideoHelper;
import com.tsingteng.cosfun.widget.MyRecycleView;
import com.tsingteng.cosfun.widget.TitleView;

import butterknife.BindView;

/**
 * 通知页面举报
 * 常胜
 * 2018.8.20
 */
public class MessageReportFragment extends BasePresenterFragment<MessageReportPresenter, MessageReportFragment> implements MessageReportContract.IMessageReportView {
    @BindView(R.id.tv_message_report_title)
    TitleView tvMessageReportTitle;
    @BindView(R.id.rv_message_report_recy)
    MyRecycleView rvMessageReportRecy;
    private int type;
    private int workId;

    public static MessageReportFragment newInstance(int type, int workId) {
        MessageReportFragment fragment = new MessageReportFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        bundle.putInt("workId", workId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected void initData(View rootView) {
        VideoHelper.getIntence().setFragment(getActivity());
        rvMessageReportRecy.isCanRefresh(false);
        Bundle bundle = getArguments();
        type = bundle.getInt("type");
        workId = bundle.getInt("workId");
        tvMessageReportTitle.setIvLeft(R.drawable.back_big_icon);
        tvMessageReportTitle.setOnTitleClickListener(new TitleView.OnTitleClickListener() {
            @Override
            public void onLeft() {
                getActivity().finish();
            }

            @Override
            public void onRight() {

            }

            @Override
            public void onRight2() {

            }
        });
        if (type == 1) {
            tvMessageReportTitle.setTitle("视频举报");
            mPresenter.loginMessageReport(1);
        } else if (type == 2 ) {
            tvMessageReportTitle.setTitle("用户举报");
            mPresenter.loginMessageReport(2);
        } else if (type == 3) {
            tvMessageReportTitle.setTitle("评论举报");
            mPresenter.loginMessageReport(3);
        } else if (type == 4) {
            tvMessageReportTitle.setTitle("私信举报");
            mPresenter.loginMessageReport(4);
        }else if (type==5){
            tvMessageReportTitle.setTitle("便当举报");
            mPresenter.loginMessageReport(1);
        }else if (type == 6){
            tvMessageReportTitle.setTitle("尬评举报");
            mPresenter.loginMessageReport(1);
        }
    }

    @Override
    protected MessageReportPresenter createPresenter() {
        return new MessageReportPresenter();
    }

    @Override
    protected View initHeader() {
        return null;
    }

    @Override
    protected MyRecycleView createRecycleView() {
        return rvMessageReportRecy;
    }

    @Override
    protected BaseQuickAdapter createAdapter() {
        return new MessageReportAdapter();
    }

    @Override
    protected void refresh() {

    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        MessageReportBean.TipoffListBean messageReportBean = (MessageReportBean.TipoffListBean) mAdapter.getData().get(position);
        Navigate.startUploadReport(getContext(),messageReportBean.getId(), messageReportBean.getMsg(), type,  workId);
    }

    @Override
    public void onLoadMoreRequested() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.message_report;
    }

    @Override
    public void showMessageReportResult(MessageReportBean messageReportBean) {
        if (messageReportBean.getTipoffList() == null) return;
        mAdapter.addData(messageReportBean.getTipoffList());
        mAdapter.loadMoreEnd();
    }
}
